package GrampasGames.splash.client;

import com.allen_sauer.gwt.voices.client.Sound;
import com.allen_sauer.gwt.voices.client.SoundController;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;


/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Main implements EntryPoint {
	GameData data = new GameData();
	ImageHandler handler = new ImageHandler();
	SoundController soundController = new SoundController();
	Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_WAV_UNKNOWN, "image/splash.wav");
	private String playerOneName="";
	private String playerTwoName="";
	private String aSize = "65px";
	private boolean gameOver=false;
	RootPanel rootPanel;
	Label onelblTitle = new Label("SPLASH ");
	Label twolblTitle = new Label("SPLASH ");
	Label onelblTitleDetails = new Label("Select the player names..");
	Label onelblPlayerOneName = new Label("Name of Player .. ");
	Label onelblPlayerTwoName = new Label("Name of Player .. ");
	Label onelblError = new Label("No text yet");
	Label twolblPlayerName = new Label("Name");
	TextBox onetbxPlayerOneText = new TextBox();
	TextBox onetbxPlayerTwoText = new TextBox();
	TextArea oneInstructions = new TextArea();
	Button onebtnConfirm = new Button("Press to select names");
	FlowPanel oneMainPanel = new FlowPanel();
	FlowPanel twoMainPanel = new FlowPanel();
	HorizontalPanel oneTitlePanel = new HorizontalPanel();
	HorizontalPanel onePlayerOnePanel = new HorizontalPanel();
	HorizontalPanel onePlayerTwoPanel = new HorizontalPanel();
	HorizontalPanel oneConfirmPanel = new HorizontalPanel();
	HorizontalPanel oneInstructionsPanel = new HorizontalPanel();
	HorizontalPanel twoTitlePanel = new HorizontalPanel();
	HorizontalPanel twoGamePanel = new HorizontalPanel();
	FlexTable gameTable = new FlexTable();
	Image oneImagePlayerOne = new Image("image/croc.png");
	Image oneImagePlayerTwo = new Image("image/tiger.png");
	Image twoImagePlayer = new Image("image/croc.png");
	Image image1 = new Image("image/one.png");
	Image image2 = new Image("image/two.png");
	Image image3 = new Image("image/three.png");
	Image image4 = new Image("image/four.png");
	Image image5 = new Image("image/five.png");
	Image image6 = new Image("image/six.png");
	Image image7 = new Image("image/seven.png");
	Image image8 = new Image("image/eight.png");
	Image image9 = new Image("image/nine.png");
	Image image10 = new Image("image/pickme.png");
	Image image11 = new Image("image/pickme.png");
	Image image12 = new Image("image/pickme.png");
	Image image13 = new Image("image/pickme.png");
	Image image14 = new Image("image/pickme.png");
	Image image15 = new Image("image/pickme.png");
	Image image16 = new Image("image/pickme.png");
	Image image17 = new Image("image/pickme.png");
	Image image18 = new Image("image/pickme.png");
	Image image19 = new Image("image/pickme.png");
	Image image20 = new Image("image/pickme.png");
	Image image21 = new Image("image/pickme.png");
	Image image22 = new Image("image/pickme.png");
	Image image23 = new Image("image/pickme.png");
	Image image24 = new Image("image/pickme.png");
	Image image25 = new Image("image/pickme.png");
	Image image26 = new Image("image/pickme.png");
	Image image27 = new Image("image/pickme.png");
	Image image28 = new Image("image/pickme.png");
	Image image29 = new Image("image/pickme.png");
	Image image30 = new Image("image/pickme.png");
	Image image31 = new Image("image/pickme.png");
	Image image32 = new Image("image/pickme.png");
	Image image33 = new Image("image/pickme.png");
	Image image34 = new Image("image/pickme.png");
	Image image35 = new Image("image/pickme.png");
	Image image36 = new Image("image/pickme.png");
	Image image37 = new Image("image/pickme.png");
	Image image38 = new Image("image/pickme.png");
	Image image39 = new Image("image/pickme.png");
	Image image40 = new Image("image/pickme.png");
	Image image41 = new Image("image/pickme.png");
	Image image42 = new Image("image/pickme.png");
	Image image43 = new Image("image/pickme.png");
	Image image44 = new Image("image/pickme.png");
	Image image45 = new Image("image/pickme.png");
	Image image46 = new Image("image/pickme.png");
	Image image47 = new Image("image/pickme.png");
	Image image48 = new Image("image/pickme.png");
	Image image49 = new Image("image/pickme.png");
	Image image50 = new Image("image/pickme.png");
	Image image51 = new Image("image/pickme.png");
	Image image52 = new Image("image/pickme.png");
	Image image53 = new Image("image/pickme.png");
	Image image54 = new Image("image/pickme.png");
	Image image55 = new Image("image/pickme.png");
	Image image56 = new Image("image/pickme.png");
	Image image57 = new Image("image/pickme.png");
	Image image58 = new Image("image/pickme.png");
	Image image59 = new Image("image/pickme.png");
	Image image60 = new Image("image/pickme.png");
	Image image61 = new Image("image/pickme.png");
	Image image62 = new Image("image/pickme.png");
	Image image63 = new Image("image/pickme.png");
	Image image64 = new Image("image/pickme.png");
	
	

	
	public void onModuleLoad() {
		sound.play();	
		rootPanel = RootPanel.get("content");
		rootPanel.getElement().getStyle().setPosition(Position.RELATIVE);
		buildViewTwo();
		buildViewOne();	
		rootPanel.add(oneMainPanel);//change to run oneMainPanel for production two MainPanel for development
	}
	
	

	private void buildViewTwo(){
		twoMainPanel.setSize("554px", "670px");
		
		twolblTitle.setStyleName("oneGameTitle");
		twolblTitle.setWidth("150px");
		twoTitlePanel.add(twolblTitle);
		twoImagePlayer.setSize("90px", "90px");
		twoTitlePanel.add(twoImagePlayer);
		twolblPlayerName.setWidth("310px");
		twolblPlayerName.setStyleName("playerName");
		twoTitlePanel.add(twolblPlayerName);
		twoMainPanel.add(twoTitlePanel);
		
		gameTable.setWidget(1, 0, image1);
		image1.setSize(aSize, aSize);
		image1.addClickHandler(handler);
		
		gameTable.setWidget(1, 1, image2);
		image2.setSize(aSize, aSize);
		image2.addClickHandler(handler);
		gameTable.setWidget(1, 2, image3);
		image3.setSize(aSize, aSize);
		image3.addClickHandler(handler);
		gameTable.setWidget(1, 3, image4);
		image4.setSize(aSize, aSize);
		image4.addClickHandler(handler);
		gameTable.setWidget(1, 4, image5);
		image5.setSize(aSize, aSize);
		image5.addClickHandler(handler);
		gameTable.setWidget(1, 5, image6);
		image6.setSize(aSize, aSize);
		image6.addClickHandler(handler);
		gameTable.setWidget(1, 6, image7);
		image7.setSize(aSize, aSize);
		image7.addClickHandler(handler);
		gameTable.setWidget(1, 7, image8);
		image8.setSize(aSize, aSize);
		image8.addClickHandler(handler);
		gameTable.setWidget(2, 0, image9);
		image9.setSize(aSize, aSize);
		image9.addClickHandler(handler);
		gameTable.setWidget(2, 1, image10);
		image10.setSize(aSize, aSize);
		image10.addClickHandler(handler);
		gameTable.setWidget(2, 2, image11);
		image11.setSize(aSize, aSize);
		image11.addClickHandler(handler);
		gameTable.setWidget(2, 3, image12);
		image12.setSize(aSize, aSize);
		image12.addClickHandler(handler);
		gameTable.setWidget(2, 4, image13);
		image13.setSize(aSize, aSize);
		image13.addClickHandler(handler);
		gameTable.setWidget(2, 5, image14);
		image14.setSize(aSize, aSize);
		image14.addClickHandler(handler);
		gameTable.setWidget(2, 6, image15);
		image15.setSize(aSize, aSize);
		image15.addClickHandler(handler);
		gameTable.setWidget(2, 7, image16);
		image16.setSize(aSize, aSize);
		image16.addClickHandler(handler);
		gameTable.setWidget(3, 0, image17);
		image17.setSize(aSize, aSize);
		image17.addClickHandler(handler);
		gameTable.setWidget(3, 1, image18);
		image18.setSize(aSize, aSize);
		image18.addClickHandler(handler);
		gameTable.setWidget(3, 2, image19);
		image19.setSize(aSize, aSize);
		image19.addClickHandler(handler);
		gameTable.setWidget(3, 3, image20);
		image20.setSize(aSize, aSize);
		image20.addClickHandler(handler);
		gameTable.setWidget(3, 4, image21);
		image21.setSize(aSize, aSize);
		image21.addClickHandler(handler);
		gameTable.setWidget(3, 5, image22);
		image22.setSize(aSize, aSize);
		image22.addClickHandler(handler);
		gameTable.setWidget(3, 6, image23);
		image23.setSize(aSize, aSize);
		image23.addClickHandler(handler);
		gameTable.setWidget(3, 7, image24);
		image24.setSize(aSize, aSize);
		image24.addClickHandler(handler);
		gameTable.setWidget(4, 0, image25);
		image25.setSize(aSize, aSize);
		image25.addClickHandler(handler);
		gameTable.setWidget(4, 1, image26);
		image26.setSize(aSize, aSize);
		image26.addClickHandler(handler);
		gameTable.setWidget(4, 2, image27);
		image27.setSize(aSize, aSize);
		image27.addClickHandler(handler);
		gameTable.setWidget(4, 3, image28);
		image28.setSize(aSize, aSize);
		image28.addClickHandler(handler);
		gameTable.setWidget(4, 4, image29);
		image29.setSize(aSize, aSize);
		image29.addClickHandler(handler);
		gameTable.setWidget(4, 5, image30);
		image30.setSize(aSize, aSize);
		image30.addClickHandler(handler);
		gameTable.setWidget(4, 6, image31);
		image31.setSize(aSize, aSize);
		image31.addClickHandler(handler);
		gameTable.setWidget(4, 7, image32);
		image32.setSize(aSize, aSize);
		image32.addClickHandler(handler);
		gameTable.setWidget(5, 0, image33);
		image33.setSize(aSize, aSize);
		image33.addClickHandler(handler);
		gameTable.setWidget(5, 1, image34);
		image34.setSize(aSize, aSize);
		image34.addClickHandler(handler);
		gameTable.setWidget(5, 2, image35);
		image35.setSize(aSize, aSize);
		image35.addClickHandler(handler);
		gameTable.setWidget(5, 3, image36);
		image36.setSize(aSize, aSize);
		image36.addClickHandler(handler);
		gameTable.setWidget(5, 4, image37);
		image37.setSize(aSize, aSize);
		image37.addClickHandler(handler);
		gameTable.setWidget(5, 5, image38);
		image38.setSize(aSize, aSize);
		image38.addClickHandler(handler);
		gameTable.setWidget(5, 6, image39);
		image39.setSize(aSize, aSize);
		image39.addClickHandler(handler);
		gameTable.setWidget(5, 7, image40);
		image40.setSize(aSize, aSize);
		image40.addClickHandler(handler);
		gameTable.setWidget(6, 0, image41);
		image41.setSize(aSize, aSize);
		image41.addClickHandler(handler);
		gameTable.setWidget(6, 1, image42);
		image42.setSize(aSize, aSize);
		image42.addClickHandler(handler);
		gameTable.setWidget(6, 2, image43);
		image43.setSize(aSize, aSize);
		image43.addClickHandler(handler);
		gameTable.setWidget(6, 3, image44);
		image44.setSize(aSize, aSize);
		image44.addClickHandler(handler);
		gameTable.setWidget(6, 4, image45);
		image45.setSize(aSize, aSize);
		image45.addClickHandler(handler);
		gameTable.setWidget(6, 5, image46);
		image46.setSize(aSize, aSize);
		image46.addClickHandler(handler);
		gameTable.setWidget(6, 6, image47);
		image47.setSize(aSize, aSize);
		image47.addClickHandler(handler);
		gameTable.setWidget(6, 7, image48);
		image48.setSize(aSize, aSize);
		image48.addClickHandler(handler);
		gameTable.setWidget(7, 0, image49);
		image49.setSize(aSize, aSize);
		image49.addClickHandler(handler);
		gameTable.setWidget(7, 1, image50);
		image50.setSize(aSize, aSize);
		image50.addClickHandler(handler);
		gameTable.setWidget(7, 2, image51);
		image51.setSize(aSize, aSize);
		image51.addClickHandler(handler);
		gameTable.setWidget(7, 3, image52);
		image52.setSize(aSize, aSize);
		image52.addClickHandler(handler);
		gameTable.setWidget(7, 4, image53);
		image53.setSize(aSize, aSize);
		image53.addClickHandler(handler);
		gameTable.setWidget(7, 5, image54);
		image54.setSize(aSize, aSize);
		image54.addClickHandler(handler);
		gameTable.setWidget(7, 6, image55);
		image55.setSize(aSize, aSize);
		image55.addClickHandler(handler);
		gameTable.setWidget(7, 7, image56);
		image56.setSize(aSize, aSize);
		image56.addClickHandler(handler);
		gameTable.setWidget(8, 0, image57);
		image57.setSize(aSize, aSize);
		image57.addClickHandler(handler);
		gameTable.setWidget(8, 1, image58);
		image58.setSize(aSize, aSize);
		image58.addClickHandler(handler);
		gameTable.setWidget(8, 2, image59);
		image59.setSize(aSize, aSize);
		image59.addClickHandler(handler);
		gameTable.setWidget(8, 3, image60);
		image60.setSize(aSize, aSize);
		image60.addClickHandler(handler);
		gameTable.setWidget(8, 4, image61);
		image61.setSize(aSize, aSize);
		image61.addClickHandler(handler);
		gameTable.setWidget(8, 5, image62);
		image62.setSize(aSize, aSize);
		image62.addClickHandler(handler);
		gameTable.setWidget(8, 6, image63);
		image63.setSize(aSize, aSize);
		image63.addClickHandler(handler);
		gameTable.setWidget(8, 7, image64);
		image64.setSize(aSize, aSize);
		image64.addClickHandler(handler);
		
		twoGamePanel.add(gameTable);
		twoMainPanel.add(twoGamePanel);
		showName();
		for (int j = 1; j<65; j++){
			showPic(j);
		}	
	}
	
	private void buildViewOne(){
		oneMainPanel.setSize("500px", "670px");		
		onelblTitle.setStyleName("oneGameTitle");
		oneTitlePanel.add(onelblTitle);
		onelblTitle.setWidth("210px");
		onelblTitleDetails.setStyleName("centerText");
		oneTitlePanel.add(onelblTitleDetails);
		onelblTitleDetails.setWidth("330px");
		oneTitlePanel.setHeight("60px");
		oneMainPanel.add(oneTitlePanel);
		onePlayerOnePanel.add(oneImagePlayerTwo);
		oneImagePlayerTwo.setAltText("Tiger Player");
		oneImagePlayerTwo.setSize("100", "100");
		onePlayerTwoPanel.add(oneImagePlayerOne);		
		oneImagePlayerOne.setAltText("Croc Player");
		oneImagePlayerOne.setSize("100", "100");
		onePlayerTwoPanel.add(onelblPlayerOneName);
		onePlayerOnePanel.setWidth("400");
		oneMainPanel.add(onePlayerTwoPanel);
		onePlayerTwoPanel.setWidth("400");
		onePlayerTwoPanel.add(onetbxPlayerOneText);
		onePlayerOnePanel.setHeight("200px");
		onePlayerTwoPanel.setHeight("200px");
		oneMainPanel.add(onePlayerOnePanel);
		onePlayerOnePanel.add(onelblPlayerTwoName);
		onePlayerOnePanel.add(onetbxPlayerTwoText);
		oneConfirmPanel.add(onebtnConfirm);	
		onebtnConfirm.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				if(!gameOver){
					playerOneName = onetbxPlayerOneText.getText();
					playerTwoName = onetbxPlayerTwoText.getText();
					if(playerOneName.length()==0 || playerTwoName.length() ==0){
						onelblError.setText("Please fill in the names..");
						onelblError.setVisible(true);
					}else{
						switchView();
						sound.play();
						oneInstructions.setVisible(false);
					}
				}else{
					data.reset();
					rootPanel.clear();
					rootPanel.add(twoMainPanel);
					for (int j = 1; j<65; j++){
						showPic(j);
					}
					showName();
					sound.play();
				}
			}});
		onebtnConfirm.setSize("250px", "50px");
		onelblError.setStyleName("centerText");
		oneConfirmPanel.add(onelblError);
		onelblError.setWidth("300px");
		onelblError.setVisible(false);
		oneConfirmPanel.setHeight("90px");
		oneMainPanel.add(oneConfirmPanel);		
		oneMainPanel.add(oneInstructionsPanel);
		oneInstructions.setText("Splash is a game played by two people taking turns to pick a card. "+
				"When a card is selected the card is increased by three, the cards one away from it "+
				"are increased by two and the cards two away are increased one in a ripple effect ("+
				"like dropping a pebble into a pond).\n\n"+
				"If a card is increased to 10 or more the card belongs to the player.  The player with the "+
				"most cards at the end of the game wins.");
		oneInstructionsPanel.add(oneInstructions);
		oneInstructions.setSize("550px", "130px");
		oneInstructionsPanel.setWidth("550px");
	}
		
	private void switchView(){
		if(playerOneName.length()>10){
			playerOneName = playerOneName.substring(0, 9);
		}
		if(playerTwoName.length()>10){
			playerTwoName = playerTwoName.substring(0, 9);
		}
		data.setPlayerOneName(playerOneName);
		data.setPlayerTwoName(playerTwoName);
		oneInstructions.setVisible(false);
		twolblPlayerName.setText(data.getPlayerOneName() + "'s turn ..");
		rootPanel.clear();
		rootPanel.add(twoMainPanel);
	}
	
	private void handleEvent(int i){
		if(data.getData(i)<10){// ignore clicks on finished cards
			// game mechanics of how to handle a click
			// inc all tiles and progressive display
			spashCard(i);		
			// reset screen
			for (int j = 1; j<65; j++){
				showPic(j);
				}	
			// swap players
			// show names
			data.swapCurrentPlayer();
			showName();
			if(data.getPlayerOneScore()+data.getPlayerTwoScore()>63){
				gameOver=true;
				sound.play();
				rootPanel.clear();
				rootPanel.add(oneMainPanel);
				onelblPlayerOneName.setText(data.getPlayerOneName() + " scored " + data.getPlayerOneScore() + " cards.");
				onelblPlayerTwoName.setText(data.getPlayerTwoName() + " scored " + data.getPlayerTwoScore() + " cards.");
				onelblPlayerOneName.setStyleName("playerName");
				onelblPlayerTwoName.setStyleName("playerName");
				onelblTitleDetails.setStyleName("oneGameTitle");
				onetbxPlayerOneText.removeFromParent();
				onetbxPlayerTwoText.removeFromParent();
				if(data.getPlayerOneScore()> data.getPlayerTwoScore()){
					onelblTitleDetails.setText(data.getPlayerOneName() + " won!!");
					}else if (data.getPlayerOneScore()< data.getPlayerTwoScore()){
						onelblTitleDetails.setText(data.getPlayerTwoName() + " won!!");
					}else{
						onelblTitleDetails.setText("Game was a draw.");
					}
				onebtnConfirm.setText("Play Again?");
			}
		}
	}
	
	private String getImage(int i){
		String temp="image/pickme.png";
			if(data.getImage(i)!=null)
				temp = data.getImage(i);
		return temp;
	}
	
	private void showName(){
		//display player name and number of cards	
		twolblPlayerName.setText(data.getCurrentPlayerName() + "'s score is " + 
				data.getCurrentPlayerScore() + " cards");
		twoImagePlayer.setUrl(getImage(data.getCurrentPlayer()));		
	}
	
	private void showPic(int i){
		switch (i){
		case 0:  break;
		case 1: image1.setUrl(getImage(data.getData(i))); break;
		case 2: image2.setUrl(getImage(data.getData(i))); break;
		case 3: image3.setUrl(getImage(data.getData(i))); break;
		case 4: image4.setUrl(getImage(data.getData(i))); break;
		case 5: image5.setUrl(getImage(data.getData(i))); break;
		case 6: image6.setUrl(getImage(data.getData(i))); break;
		case 7: image7.setUrl(getImage(data.getData(i))); break;
		case 8: image8.setUrl(getImage(data.getData(i))); break;
		case 9: image9.setUrl(getImage(data.getData(i))); break;
		case 10: image10.setUrl(getImage(data.getData(i))); break;
		case 11: image11.setUrl(getImage(data.getData(i))); break;
		case 12: image12.setUrl(getImage(data.getData(i))); break;
		case 13: image13.setUrl(getImage(data.getData(i))); break;
		case 14: image14.setUrl(getImage(data.getData(i))); break;
		case 15: image15.setUrl(getImage(data.getData(i))); break;
		case 16: image16.setUrl(getImage(data.getData(i))); break;
		case 17: image17.setUrl(getImage(data.getData(i))); break;
		case 18: image18.setUrl(getImage(data.getData(i))); break;
		case 19: image19.setUrl(getImage(data.getData(i))); break;
		case 20: image20.setUrl(getImage(data.getData(i))); break;
		case 21: image21.setUrl(getImage(data.getData(i))); break;
		case 22: image22.setUrl(getImage(data.getData(i))); break;
		case 23: image23.setUrl(getImage(data.getData(i))); break;
		case 24: image24.setUrl(getImage(data.getData(i))); break;
		case 25: image25.setUrl(getImage(data.getData(i))); break;
		case 26: image26.setUrl(getImage(data.getData(i))); break;
		case 27: image27.setUrl(getImage(data.getData(i))); break;
		case 28: image28.setUrl(getImage(data.getData(i))); break;
		case 29: image29.setUrl(getImage(data.getData(i))); break;
		case 30: image30.setUrl(getImage(data.getData(i))); break;
		case 31: image31.setUrl(getImage(data.getData(i))); break;
		case 32: image32.setUrl(getImage(data.getData(i))); break;
		case 33: image33.setUrl(getImage(data.getData(i))); break;
		case 34: image34.setUrl(getImage(data.getData(i))); break;
		case 35: image35.setUrl(getImage(data.getData(i))); break;
		case 36: image36.setUrl(getImage(data.getData(i))); break;
		case 37: image37.setUrl(getImage(data.getData(i))); break;
		case 38: image38.setUrl(getImage(data.getData(i))); break;
		case 39: image39.setUrl(getImage(data.getData(i))); break;
		case 40: image40.setUrl(getImage(data.getData(i))); break;
		case 41: image41.setUrl(getImage(data.getData(i))); break;
		case 42: image42.setUrl(getImage(data.getData(i))); break;
		case 43: image43.setUrl(getImage(data.getData(i))); break;
		case 44: image44.setUrl(getImage(data.getData(i))); break;
		case 45: image45.setUrl(getImage(data.getData(i))); break;
		case 46: image46.setUrl(getImage(data.getData(i))); break;
		case 47: image47.setUrl(getImage(data.getData(i))); break;
		case 48: image48.setUrl(getImage(data.getData(i))); break;
		case 49: image49.setUrl(getImage(data.getData(i))); break;
		case 50: image50.setUrl(getImage(data.getData(i))); break;
		case 51: image51.setUrl(getImage(data.getData(i))); break;
		case 52: image52.setUrl(getImage(data.getData(i))); break;
		case 53: image53.setUrl(getImage(data.getData(i))); break;
		case 54: image54.setUrl(getImage(data.getData(i))); break;
		case 55: image55.setUrl(getImage(data.getData(i))); break;
		case 56: image56.setUrl(getImage(data.getData(i))); break;
		case 57: image57.setUrl(getImage(data.getData(i))); break;
		case 58: image58.setUrl(getImage(data.getData(i))); break;
		case 59: image59.setUrl(getImage(data.getData(i))); break;
		case 60: image60.setUrl(getImage(data.getData(i))); break;
		case 61: image61.setUrl(getImage(data.getData(i))); break;
		case 62: image62.setUrl(getImage(data.getData(i))); break;
		case 63: image63.setUrl(getImage(data.getData(i))); break;
		case 64: image64.setUrl(getImage(data.getData(i))); break;
		default:break;
		}
	}
	
	private void spashCard(int i){
		switch (i){
		case 0:  break;
		case 1: data.incByThree(i); 
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 2: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15);
		break;
		case 3: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 4: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 5: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 6: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 7: data.incByThree(i);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+17); data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 8: data.incByThree(i);
		data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1); 
		data.incByOne(i+16);
		data.incByOne(i+15); data.incByOne(i+14); data.incByOne(i+6); data.incByOne(i-2);
		break;
		case 9: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 10: data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9); data.incByTwo(i-8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);  data.incByOne(i+15); 
		break;
		case 11: data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9); data.incByTwo(i-8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 12: data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9);  data.incByTwo(i-8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 13:  data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9); data.incByTwo(i-8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 14:  data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9); data.incByTwo(i-8);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 15: data.incByThree(i);
		data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9); data.incByTwo(i-8);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 16: data.incByThree(i);
		data.incByTwo(i+8); data.incByTwo(i+7); data.incByTwo(i-1); data.incByTwo(i-9);
		data.incByTwo(i-8);
		data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10); 
		break;
		case 17: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 18: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); 
		break;
		case 19: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 20: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 21: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 22: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 23: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 24: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); 
		data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 25: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 26: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); 
		break;
		case 27: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 28: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 29: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 30: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 31: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 32: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); 
		data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 33: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 34: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); 
		break;
		case 35: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 36: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 37: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 38: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 39: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 40: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); 
		data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 41: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18); 
		data.incByOne(i+17); data.incByOne(i+16);
		break;
		case 42: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); 
		break;
		case 43: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 44: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 45: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 46:data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); data.incByOne(i+18);
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 47: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); 
		data.incByOne(i+17); data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 48: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); 
		data.incByOne(i+16); data.incByOne(i+15); data.incByOne(i+14);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 49: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); data.incByTwo(i+9);
		data.incByTwo(i+8);
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); 
		break;
		case 50: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10); 
		break;
		case 51: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 52: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 53: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 54: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i+10);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 55: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i+9); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 56:  data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i+8);
		data.incByTwo(i+7); data.incByTwo(i-1);
		data.incByOne(i+6); data.incByOne(i-2); data.incByOne(i-10);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16);
		break;
		case 57: data.incByThree(i);
		data.incByTwo(i-8); data.incByTwo(i-7); data.incByTwo(i+1); 
		data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14);
		data.incByOne(i-6); data.incByOne(i+2);
		break;
		case 58: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i-1);
		data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); 
		break;
		case 59: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 60:data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 61:  data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2); data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 62: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1); data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-14); 
		data.incByOne(i-6); data.incByOne(i+2);  data.incByOne(i-2); data.incByOne(i-10);
		break;
		case 63: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8);  data.incByTwo(i-7);
		data.incByTwo(i+1);  data.incByTwo(i-1);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16); data.incByOne(i-15); data.incByOne(i-2); 
		data.incByOne(i-10);
		break;
		case 64: data.incByThree(i);
		data.incByTwo(i-9); data.incByTwo(i-8); data.incByTwo(i-1);
		data.incByOne(i-2); data.incByOne(i-10);
		data.incByOne(i-18); data.incByOne(i-17); data.incByOne(i-16);
		break;
		default:break;
		}
	}
	
	public class ImageHandler implements ClickHandler{
		@Override
		public void onClick(ClickEvent event) {
			Widget image = (Widget) event.getSource();
			int number = 0;
			if(image == image1){number = 1;}
			if(image == image2){number = 2;}
			if(image == image3){number = 3;}
			if(image == image4){number = 4;}
			if(image == image5){number = 5;}
			if(image == image6){number = 6;}
			if(image == image7){number = 7;}
			if(image == image8){number = 8;}
			if(image == image9){number = 9;}
			if(image == image10){number = 10;}
			if(image == image11){number = 11;}
			if(image == image12){number = 12;}
			if(image == image13){number = 13;}
			if(image == image14){number = 14;}
			if(image == image15){number = 15;}
			if(image == image16){number = 16;}
			if(image == image17){number = 17;}
			if(image == image18){number = 18;}
			if(image == image19){number = 19;}
			if(image == image20){number = 20;}
			if(image == image21){number = 21;}
			if(image == image22){number = 22;}
			if(image == image23){number = 23;}
			if(image == image24){number = 24;}
			if(image == image25){number = 25;}
			if(image == image26){number = 26;}
			if(image == image27){number = 27;}
			if(image == image28){number = 28;}
			if(image == image29){number = 29;}
			if(image == image30){number = 30;}
			if(image == image31){number = 31;}
			if(image == image32){number = 32;}
			if(image == image33){number = 33;}
			if(image == image34){number = 34;}
			if(image == image35){number = 35;}
			if(image == image36){number = 36;}
			if(image == image37){number = 37;}
			if(image == image38){number = 38;}
			if(image == image39){number = 39;}
			if(image == image40){number = 40;}
			if(image == image41){number = 41;}
			if(image == image42){number = 42;}
			if(image == image43){number = 43;}
			if(image == image44){number = 44;}
			if(image == image45){number = 45;}
			if(image == image46){number = 46;}
			if(image == image47){number = 47;}
			if(image == image48){number = 48;}
			if(image == image49){number = 49;}
			if(image == image50){number = 50;}
			if(image == image51){number = 51;}
			if(image == image52){number = 52;}
			if(image == image53){number = 53;}
			if(image == image54){number = 54;}
			if(image == image55){number = 55;}
			if(image == image56){number = 56;}
			if(image == image57){number = 57;}
			if(image == image58){number = 58;}
			if(image == image59){number = 59;}
			if(image == image60){number = 60;}
			if(image == image61){number = 61;}
			if(image == image62){number = 62;}
			if(image == image63){number = 63;}
			if(image == image64){number = 64;}
			
			if(number!=0){
				handleEvent(number);
			}		
		}		
	}//Close inner class imageHandler
}
	
	
